#ifndef Scenic_Renderer_Image_h
#define Scenic_Renderer_Image_h


#include "Resource.h"


namespace Scenic 
{ 
namespace Renderer
{

class Texture;

struct ImageBlock
{
	Texture *texture;
	int x;
	int y;
	int width;
	int height;
	float maxS;
	float maxT;
};

class Image : public Resource
{
	ImageBlock *blocks;
	int numCols;
	int numRows;
public:
	int width;
	int height;
	Format format;
	int options;

	Image();
	~Image();

	int getNumCols() { return numCols; }
	int getNumRows() { return numRows; }
	ImageBlock *getBlock(int row, int col);

	bool create(int width, int height, Format format, int options = 0);
	void free(bool isAsync = false);
	void write(int x, int y, int width, int height, char *data, int pitch);
	bool contentsLost();
private:
	void updateJavaObject();
};

Image *getImage(int id);

}
}

#endif
